home *** CD-ROM | disk | FTP | other *** search
/ BBS Toolkit / BBS Toolkit.iso / windows / mrun211.zip / NEWFILES.WAS < prev    next >
Text File  |  1993-05-01  |  5KB  |  177 lines

  1. ;MailRun 2.1 add-in script for new file scans 
  2.  
  3.  
  4. ;Note that this script uses the value of TaskItem (the currently selected
  5. ;line in the Task List) to determine the current BBS.  It will therefore
  6. ;not function properly when the user manually changes the selected item
  7. ;just prior to execution of this script.
  8.  
  9.  
  10. #define BBS s3
  11. #define TempDir s6
  12. #define MailRunIni s7
  13. #define MailRun s8
  14. #define TaskItem s9
  15. #define IdleTimer i0
  16. #define AnsiInLog i5
  17. #define LogRun i7
  18.  
  19. string prompt, BBSType
  20. integer holdstatus 
  21.  
  22. proc main
  23. string BBSLst, CapFile, TmpCap, MailRunDir
  24.     ;find last default capture file
  25.     fetch capture file CapFile
  26.     ;change the default capture file
  27.     capture OFF
  28.     set capture file "_tmp.cap"
  29.     set capture mode create VISUAL
  30.     capture ON
  31.     
  32.     ;find current BBSType, etc.
  33.     profilerd MailRun BBS "BBSType" BBSType
  34.     profilerd MailRunIni "MailRun" "MailRunDir" MailRunDir
  35.     if !(findstring(BBSType, "PCBoard"))
  36.         when quiet 1 call checkfileprompt
  37.         holding()
  38.         clearwhen quiet
  39.     endif
  40.     if findstring(BBSType, "Auntie")
  41.         transmit "LN;;^M"
  42.     elseif findstring(BBSType, "PCBoard")
  43.         transmit "N;U^M"
  44.     elseif findstring(BBSType, "WildCat")
  45.         transmit "N^M"
  46.     elseif findstring(BBSType, "RBBS")
  47.         transmit "N;S;A^M"
  48.     endif
  49.     when quiet 1 call checkprompt
  50.     holding()
  51.     clearwhen quiet
  52.     capture OFF
  53.     if !(findstring(BBSType, "PCBoard"))
  54.         when quiet 1 call checkmainprompt
  55.         holding()
  56.         clearwhen quiet
  57.     endif
  58.     BBSLst = makefullname(MailRunDir, BBS)
  59.     strcat BBSLst ".lst"
  60.     TmpCap = makefullname(MailRunDir, "_tmp.cap")
  61.     copyfile TmpCap BBSLst
  62.     delfile TmpCap
  63.     set capture file CapFile
  64.     if LogRun
  65.         if AnsiInLog
  66.             set capture mode append RAW
  67.         else
  68.             set capture mode append VISUAL
  69.         endif
  70.         capture ON
  71.     endif
  72. endproc
  73.  
  74. proc checkprompt
  75. string CommandPrompt, FilePrompt, MorePrompt, ContinuePrompt
  76.     profilerd MailRun BBS "CommandPrompt" CommandPrompt
  77.     profilerd MailRun BBS "FilePrompt" FilePrompt
  78.     profilerd MailRun BBS "MorePrompt" MorePrompt
  79.     profilerd MailRun BBS "ContinuePrompt" ContinuePrompt
  80.     if findstring(prompt, CommandPrompt) || findstring(prompt, FilePrompt)
  81.         endhold()
  82.     elseif findstring(BBSType, "Auntie") && findstring(prompt, "More (")
  83.         transmit "NS^M"
  84.     elseif findstring(prompt, MorePrompt)
  85.         transmit "NS^M"
  86.     elseif findstring(BBSType, "Auntie") && findstring(prompt, ContinuePrompt)        
  87.         transmit "^M"
  88.     elseif findstring(prompt, ContinuePrompt) 
  89.         transmit "y^M"
  90.     elseif findstring(BBSType, "WildCat") && findstring(prompt, "[L]ast new")
  91.         transmit "L^M"
  92.     elseif (findstring(BBSType, "PCBoard") && \
  93.         findstring(prompt, "(Enter)=?")) || (findstring(BBSType, "WildCat") && \
  94.         findstring(prompt, "ENTER = All"))
  95.         transmit "^M"
  96.     endif
  97. endproc
  98.  
  99. proc checkfileprompt
  100. string FilePrompt, CommandPrompt
  101.     profilerd MailRun BBS "FilePrompt" FilePrompt
  102.     profilerd MailRun BBS "CommandPrompt" CommandPrompt
  103.     if findstring(prompt, CommandPrompt)
  104.         transmit "f^M"
  105.     elseif findstring(prompt, FilePrompt)
  106.         endhold()
  107.     endif
  108. endproc
  109.  
  110. proc checkmainprompt
  111. string FilePrompt, CommandPrompt
  112.     profilerd MailRun BBS "FilePrompt" FilePrompt
  113.     profilerd MailRun BBS "CommandPrompt" CommandPrompt
  114.     if findstring(prompt, FilePrompt)
  115.         if !(findstring(BBSType, "RBBS"))
  116.             transmit "q^M"
  117.         else
  118.             transmit "q;m^M"
  119.         endif
  120.     elseif findstring(prompt, CommandPrompt)
  121.         endhold()
  122.     endif
  123. endproc
  124.  
  125. proc holding
  126. string LastPrompt
  127. integer IdleTimeout
  128.     profilerd MailRun "MailRun" "IdleTimeout" IdleTimeout
  129.     IdleTimer = 1
  130.     holdstatus = 1
  131.     prompt = ""
  132.     while (IdleTimer < IdleTimeout) && (holdstatus == 1) && $CARRIER
  133.         pause 1
  134.         termgets $ROW 0 prompt 75
  135.         if not strcmp prompt LastPrompt
  136.             ;if anything has been received, reset the timer
  137.             IdleTimer = 1
  138.         endif
  139.         LastPrompt = prompt
  140.         IdleTimer++
  141.     endwhile
  142.     if (IdleTimer == IdleTimeout) || ($CARRIER == 0)
  143.         ;If there has been a timeout, lost carrier or user escape...
  144.         clearwhen quiet
  145.         ;set FailCode and get out
  146.         if IdleTimer == IdleTimeout
  147.             capturestr "`r`n`r`n***** Timed out waiting for prompt *****`r`n`r`n"
  148.         else
  149.             capturestr "`r`n`r`n************* Lost carrier *************`r`n`r`n"
  150.         endif
  151.     endif
  152. endproc
  153.  
  154. proc endhold
  155.     holdstatus = 0
  156. endproc
  157.  
  158. func findstring : integer
  159. strparm String1, String2
  160. integer i = 0
  161.     if not NULLSTR String2
  162.         if strfind String1 String2
  163.             i = 1
  164.         endif
  165.     endif
  166.     return i
  167. endfunc
  168.  
  169. func makefullname : string
  170. strparm Directory, FileNamen
  171. string FullName
  172.     FullName = Directory
  173.     addfilename FullName FileNamen
  174.     return FullName
  175. endfunc
  176.  
  177.